package com.project.workjob.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.project.workjob.dto.WorkCalendarParam;
import com.project.workjob.entity.WorkCalendar;
import com.project.workjob.mapper.WorkCalendarMapper;
import com.project.workjob.service.WorkCalendarService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WorkCalendarServiceImpl implements WorkCalendarService {

    @Resource
    private WorkCalendarMapper workCalendarMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    @DS("master")
    public void deleteByMonth(WorkCalendarParam param) {
        workCalendarMapper.deleteByYear(param);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    @DS("master")
    public void insert(List<WorkCalendar> list) {
        for (WorkCalendar workCalendar : list) {
            workCalendarMapper.insertSelective(workCalendar);
        }
    }
}
